import $ from "jquery";
import {url} from "../../util/config";
import {message} from "antd";
import login from "../login";
function getNewLogin(item) {
    return setUserLog(item)
}
export default function setUserLog(item){
    let token = localStorage.getItem("token")
    let status;
    $.ajax({
        async:true,
        headers: {
            'Accept': "application/json",
            'Authorization': token
        },
        url: url.api_url+`Log/userAccessLog`,
        type: 'post',
        contentType:"application/json",
        data:JSON.stringify({title:item.title,type:item.type,id:item.id}),
        success: function (result) {
            if(result.result=="Token過期請重新登錄"){
                login(localStorage.getItem("account"), localStorage.getItem("password"));
                status = getNewLogin(item)
            }else {
                console.log("getDatasForMove:",result)
                status = result.result
            }
        },
        error:function (error) {
            message.error("请求异常");
            status = "error"
        }
    })
    return status;
}
